﻿#region Disclaimer/Info
///////////////////////////////////////////////////////////////////////////////////////////////////
// MetaCollection
// 
// MetaCollection is a system to provide a standard structure, permissions and metadata service
// for content organization.
//
// This project is hosted at Google Code at http://code.google.com/p/metacollection/
//
// This project is licensed under the BSD license.  See the License.txt file for more information.
///////////////////////////////////////////////////////////////////////////////////////////////////
#endregion

using System;

namespace MetaCollection.Framework.Model
{
	/// <summary>
	/// The AccessFlags Enumeration represents a set of binary flags used in controlling
	/// access to MetaCollection Items.
	/// <example>
	/// To access a permissions attribute specifically from the flags use the 
	/// binary operators on the object in the following way.  This example assumes that 
	/// <c>itemRights</c> as an instance of the <see cref="AccessFlags"/> enumeration.
	/// <code>
	/// if ((itemRights &amp; AccessFlags.Append) == AccessFlags.Append) 
	///	{
	///     // append rights required code here
	/// }
	/// </code>
	/// </example>
	/// </summary>
	[Flags]
	public enum AccessRights : int
	{
		/// <summary>
		/// No Permissions Granted
		/// </summary>
		None = 0,
		/// <summary>
		/// Read Resource indicates that the claim assigns a principal the ability to read the resource
		/// </summary>
		ReadResource = 1,
		/// <summary>
		/// Read Metadata for object.  Metadata is typically stored as Item Properties
		/// </summary>
		ReadProperties = 1 << 1,
		/// <summary>
		/// Principal is allowed to view the claims assigned to the item.
		/// </summary>
		ReadItemClaims = 1 << 2,
		/// <summary>
		/// Add/Update/Delete the resource associated with the item
		/// </summary>
		WriteResource = 1 << 3,
		/// <summary>
		/// Add/Update/Delete Item Properties
		/// </summary>
		WriteProperties = 1 << 4,
		/// <summary>
		/// Add/Update/Delete Item Claims.
		/// </summary>
		WriteItemClaims = 1 << 5,
		/// <summary>
		/// Delete object (includes item and item resources)
		/// </summary>
		DeleteItem = 1 << 6,
		/// <summary>
		/// Permission to add Item records with parent id set to an Item which contains a 
		/// satisfied claim with this permission
		/// </summary>
		Append = 1 << 7,
		/// <summary>
		/// Permission to change the owner of this item.
		/// </summary>
		/// <remarks>
		/// The owner of an item typically has additional access assigned beyond the rights given
		/// to regular users.  This allows DeleteItem rights to be denied to users while allowing
		/// any user that creates an item to have the ability to delete it through the content owner
		/// rights.
		/// </remarks>
		ModifyOwnership = 1 << 8,
		/// <summary>
		/// Used for setting the Published Version flag of the Item. This 
		/// column indicates the current active version as apposed to draft or historic versions
		/// </summary>
		ModifyPublishedVersion = 1 << 9,
		/// <summary>
		/// Indicate that this AccessRight represents an unknown or undetermined type.
		/// </summary>
		/// <remarks>
		/// When applied to a demand this value indicates that further processing is required to 
		/// determine the rights required.  For example in Saving an item the initial evaluation may be
		/// "Unknown" rights required since depending on the changes being made WriteResource, WriteProperties
		/// or even WriteItemClaims maybe required.
		/// When applied to a rights grant this value represents a permission that is not defined or supported
		/// and will be ignored in the processing of of rights as granted for a demand set.
		/// </remarks>
		Unknown = 1 << 10,
		/// <summary>
		/// All read type permissions
		/// </summary>
		AllReadType = ReadResource | ReadProperties | ReadItemClaims,
		/// <summary>
		/// All write type permissions
		/// </summary>
		AllWriteType = WriteResource | WriteProperties | WriteItemClaims | Append,
		/// <summary>
		/// Full permission to object including administrative functions.
		/// </summary>
		FullControl = AllReadType | AllWriteType | DeleteItem | ModifyOwnership | ModifyPublishedVersion
	}
}
